/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package reamodel.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import reamodel.Commitment;
import reamodel.EconomicResource;
import reamodel.EconomicResourceType;
import reamodel.InflowType;
import reamodel.OutflowType;
import reamodel.ReamodelPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Economic Resource Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link reamodel.impl.EconomicResourceTypeImpl#getName <em>Name</em>}</li>
 *   <li>{@link reamodel.impl.EconomicResourceTypeImpl#getTypify <em>Typify</em>}</li>
 *   <li>{@link reamodel.impl.EconomicResourceTypeImpl#getSpecify <em>Specify</em>}</li>
 *   <li>{@link reamodel.impl.EconomicResourceTypeImpl#getInflowType <em>Inflow Type</em>}</li>
 *   <li>{@link reamodel.impl.EconomicResourceTypeImpl#getOutflowType <em>Outflow Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EconomicResourceTypeImpl extends EObjectImpl implements EconomicResourceType {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTypify() <em>Typify</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypify()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicResource> typify;

	/**
	 * The cached value of the '{@link #getSpecify() <em>Specify</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSpecify()
	 * @generated
	 * @ordered
	 */
	protected EList<Commitment> specify;

	/**
	 * The cached value of the '{@link #getInflowType() <em>Inflow Type</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInflowType()
	 * @generated
	 * @ordered
	 */
	protected EList<InflowType> inflowType;

	/**
	 * The cached value of the '{@link #getOutflowType() <em>Outflow Type</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutflowType()
	 * @generated
	 * @ordered
	 */
	protected EList<OutflowType> outflowType;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EconomicResourceTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ReamodelPackage.Literals.ECONOMIC_RESOURCE_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ReamodelPackage.ECONOMIC_RESOURCE_TYPE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicResource> getTypify() {
		if (typify == null) {
			typify = new EObjectWithInverseResolvingEList<EconomicResource>(EconomicResource.class, this, ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY, ReamodelPackage.ECONOMIC_RESOURCE__TYPIFIED_BY);
		}
		return typify;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Commitment> getSpecify() {
		if (specify == null) {
			specify = new EObjectWithInverseResolvingEList.ManyInverse<Commitment>(Commitment.class, this, ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY, ReamodelPackage.COMMITMENT__RESOURCE);
		}
		return specify;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<InflowType> getInflowType() {
		if (inflowType == null) {
			inflowType = new EObjectWithInverseResolvingEList<InflowType>(InflowType.class, this, ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE, ReamodelPackage.INFLOW_TYPE__RESOURCE_TYPE);
		}
		return inflowType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OutflowType> getOutflowType() {
		if (outflowType == null) {
			outflowType = new EObjectWithInverseResolvingEList<OutflowType>(OutflowType.class, this, ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE, ReamodelPackage.OUTFLOW_TYPE__RESOURCE_TYPE);
		}
		return outflowType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getTypify()).basicAdd(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getSpecify()).basicAdd(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getInflowType()).basicAdd(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutflowType()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				return ((InternalEList<?>)getTypify()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				return ((InternalEList<?>)getSpecify()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				return ((InternalEList<?>)getInflowType()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				return ((InternalEList<?>)getOutflowType()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__NAME:
				return getName();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				return getTypify();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				return getSpecify();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				return getInflowType();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				return getOutflowType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__NAME:
				setName((String)newValue);
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				getTypify().clear();
				getTypify().addAll((Collection<? extends EconomicResource>)newValue);
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				getSpecify().clear();
				getSpecify().addAll((Collection<? extends Commitment>)newValue);
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				getInflowType().clear();
				getInflowType().addAll((Collection<? extends InflowType>)newValue);
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				getOutflowType().clear();
				getOutflowType().addAll((Collection<? extends OutflowType>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				getTypify().clear();
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				getSpecify().clear();
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				getInflowType().clear();
				return;
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				getOutflowType().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__TYPIFY:
				return typify != null && !typify.isEmpty();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__SPECIFY:
				return specify != null && !specify.isEmpty();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__INFLOW_TYPE:
				return inflowType != null && !inflowType.isEmpty();
			case ReamodelPackage.ECONOMIC_RESOURCE_TYPE__OUTFLOW_TYPE:
				return outflowType != null && !outflowType.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //EconomicResourceTypeImpl
